package com.shujia.mr.wc2;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class HarrayMapper extends Mapper<LongWritable, Text,Text,LongWritable> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        //数据清洗
        String line = value.toString();
        String newLine = line.replaceAll(",", "").replaceAll("\\.", "");

        String[] words = newLine.split(" ");
        for (String word : words) {
            String newWord = word.toLowerCase();
            context.write(new Text(newWord),new LongWritable(1L));
        }

    }
}
